package me.zd.tool.hardlink;

import me.zd.tool.hardlink.controller.IStartupController;

import java.util.LinkedHashMap;
import java.util.Map;

public class Main {

    public static void main(String[] args) {
        Map<String,String> argMap = analyzeArgs(args);
        if (argMap.isEmpty()) {
            // 启动GUI界面
            IStartupController.GUI.startup(argMap);
        } else {
            // 命令行模式
            IStartupController.CMD.startup(argMap);
        }
    }

    private static Map<String, String> analyzeArgs(String[] args) {
        Map<String, String> map = new LinkedHashMap<>();
        for (int i = 0; i < args.length; i++) {
            String arg = args[i];
            if (arg.startsWith("--")) {
                String[] ary = arg.substring(2).split("=");
                map.put(ary[0], ary[1]);
            } else if (arg.startsWith("-")) {
                map.put(arg.substring(1), null);
            } else {
                break;
            }
        }
        return map;
    }
}
